home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tpshar20.zip / ABSHARE.INT < prev    next >
Text File  |  1992-11-23  |  2KB  |  93 lines

  1. Unit ABShare;
  2. {
  3.   Share & Record Locking Routines for TP 6.0, TP 7.0, & BP 7.0
  4.  
  5.   Copyright (c) 1992 ABSoft - ALL RIGHTS RESERVED
  6.  
  7.   1.00
  8.   1.10  Added File Mode Constants
  9.   1.11  Minor Optimizations
  10.   2.00  Updated for TP 7.0 & BP 7.0
  11. }
  12.  
  13. {$A-,B-,D-,E-,F+,G-,I-,L-,N-,O+,R-,S-,V-,X-}
  14.  
  15. {$IFDEF VER70}
  16.   {$P-,Q-,T-,Y-}
  17. {$ENDIF}
  18.  
  19. {$IFDEF PMODE}
  20.   {$G+}
  21. {$ENDIF}
  22.  
  23. Interface
  24.  
  25. Const
  26.  
  27. {
  28.  FileMode Constants - use with typed or untyped files, does not affect
  29.                       text files
  30.  
  31.  Example:
  32.  (open a file in read only, deny none mode, without changing the
  33.   global file mode)
  34.  
  35.  Var
  36.    F        : File;
  37.    SaveMode : Byte;
  38. ...
  39.  Assign(F, filename);
  40.  SaveMode := FileMode;
  41.  FileMode := OnlyRead or DenyNone;
  42.  Reset(F);
  43.  FileMode := SaveMode;
  44. ...
  45. }
  46.  
  47.   OnlyRead   = 0;
  48.   OnlyWrite  = 1;
  49.   ReadWrite  = 2;
  50.  
  51.   DenyAll    = 16;
  52.   DenyWrite  = 32;
  53.   DenyRead   = 48;
  54.   DenyNone   = 64;
  55.  
  56. Function  LockRec(FileHandle : Word; FilePosition, FileLength : LongInt;
  57.                   UnLock : Boolean) : Word;
  58. {
  59.  Lock or UnLock a Region of a File for exclusive access.  Share must
  60.  be loaded.  A call to Lock must be followed by a call to UnLock
  61.  with the same FilePosition and FileLength.  Usually used with a file
  62.  opened in ReadWrite+DenyNone mode.
  63.  
  64.  FileHandle   - FileRec(f).Handle, f is a variable of type file
  65.  FilePosition - Offset of Region to Lock/UnLock
  66.  FileLength   - Length of Region to Lock/UnLock
  67.  UnLock       - True to UnLock, False to Lock
  68.  
  69.  Returns:
  70.    00h - successful
  71.    01h - function number invalid
  72.    06h - invalid handle
  73.    21h - lock violation
  74.    24h - sharing buffer overflow
  75. }
  76.  
  77. Function  UpdateFile(FileHandle : Word) : Word;
  78. {
  79.  Updates a file to disk by opening and closing a duplicate handle
  80.  
  81.  FileHandle - FileRec(f).Handle, f is a variable of type file
  82.  
  83.  Returns:
  84.    00h - successful
  85.    04h - too many open files (no handles available)
  86.    06h - invalid handle
  87. }
  88.  
  89. Function  ShareInstalled : Boolean;
  90. {
  91.  Returns True if Share is Installed, otherwise False
  92. }
  93.